<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of tt_smv</title>
  <meta name="keywords" content="tt_smv">
  <meta name="description" content="function [res]=tt_smv(sttm, vec)">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">exp</a> &gt; tt_smv.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/exp&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>tt_smv
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [res]=tt_smv(sttm, vec)</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [res]=tt_smv(sttm, vec) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> function [res]=tt_smv(sttm, vec)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>	Mode sizes of the TT-matrix</li><li><a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>	Reshape of the TT-tensor</li><li><a href="../../tt2/@tt_tensor/size.html" class="code" title="function [sz] = size(tt,dim)">size</a>	Mode sizes of the TT-tensor</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/solve/tt_iterapp.html" class="code" title="function y = tt_iterapp(op,afun,atype,afcnstr,x,eps,max_rank,max_swp,varargin)">tt_iterapp</a>	Apply TT matrix operator to TT vector and error gracefully.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">% function [res]=tt_smv(sttm, vec)</span>
0002 
0003 <a name="_sub0" href="#_subfunctions" class="code">function [res]=tt_smv(sttm, vec)</a>
0004 <span class="comment">%TT-matrix with sparse factors by TT-vector multiplication</span>
0005 <span class="comment">%   [res]=TT_SMV(STTM,VEC) Multiplies the TT-matrix stored in the TT1.0</span>
0006 <span class="comment">%   format but with &quot;sparse&quot; cores by a vector VEC</span>
0007 <span class="comment">%</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% TT-Toolbox 2.2, 2009-2012</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets et al.</span>
0012 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0013 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0014 <span class="comment">%</span>
0015 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0016 <span class="comment">%ivan.oseledets@gmail.com</span>
0017 <span class="comment">%---------------------------</span>
0018 
0019 
0020 d=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(vec,1);
0021 res=cell(d,1);
0022 
0023 n=sttm{d+2}(1);
0024 <span class="comment">% m=size(vec{1},1);</span>
0025 rm1=sttm{d+1}(1);
0026 rv1=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(vec{1},2);
0027 <span class="comment">%mat{1} is (n x m x rm1 , vec{1} is mxrv1)</span>
0028 <span class="comment">%            n x rm1 x rv1</span>
0029 res{1}=sttm{1}*vec{1};
0030 res{1}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(permute(<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(res{1},[n,rm1,rv1]),[1,3,2]),[n,rv1*rm1]);
0031 
0032 n=sttm{d+2}(d);
0033 <span class="comment">% m=size(mat{d},2);</span>
0034 rm1=sttm{d+1}(d-1);
0035 rv1=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(vec{d},2);
0036 <span class="comment">%mat{1} is (n x rm1 x rv1 , vec{1} is mxrv1)</span>
0037 res{d}=sttm{d}*vec{d};
0038 res{d}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(permute(<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(res{d},[n,rm1,rv1]),[1,3,2]),[n,rv1*rm1]);
0039 <span class="keyword">for</span> i=2:d-1
0040     n=sttm{d+2}(i);
0041     m=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(vec{i},1);
0042     rm1=sttm{d+1}(i-1);
0043     rm2=sttm{d+1}(i);
0044     rv1=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(vec{i},2);
0045     rv2=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(vec{i},3);
0046     <span class="comment">%mat{i} is n x m x rm1 x rm2, vec{i} is m x rv1 x rv2</span>
0047     <span class="comment">%n x (rv1*rv2)*rm1*rm2</span>
0048     <span class="comment">%n x rm2 x rm1 x m, n x rm2 x rm1 x (rv1*rv2)</span>
0049     <span class="comment">%n x rm2 x rmx1 x rv1 x rv2</span>
0050     <span class="comment">%want: n x rv1*rm1 x rv2*rm2</span>
0051     res{i}=sttm{i}*<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(vec{i},[m,rv1*rv2]);
0052     res{i}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(res{i},[n,rm2,rm1,rv1,rv2]);
0053     res{i}=permute(res{i},[1,4,3,5,2]);
0054     res{i}=<a href="../../tt2/@tt_tensor/reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(res{i},[n,rv1*rm1,rv2*rm2]);
0055     <span class="comment">%res{i}=permute(reshape(permute(mat{i},[1,3,4,2])*reshape(vec{i},[m,rv1*rv2]),[n,rv1,rv2,rm1,rm2]),[1,2,4,3,5]);</span>
0056 <span class="keyword">end</span> 
0057 
0058 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>